<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link rel="stylesheet" type="text/css" href="css/acceptOrderList.css"/>
		<script src="js/jquery-2.1.0.js"></script>
		<script>
			<!-- 将数据请求下来-->
			$.ajax("/fengwei/PreOrder/getSeller",{
				type:"get",
				data:{},
				success:function(data){
					console.log(data)
					var dataObj = eval('('+data+')');
					if(dataObj.length<1){
						alert("还没有订单，去接单，或者您不是卖家")
					}
					for(var i = 0;i<dataObj.length;i++){
						var orderList = document.getElementById('orderList');
						var newDiv = document.createElement('div');//创建一个新的div
						newDiv.setAttribute('id', 'order_goods');
						newDiv.setAttribute('class', dataObj[i].preorderId);
						orderList.appendChild(newDiv);
						newDiv.innerHTML = "<div class='order_goods_msg'>名称：<span class='goods_name'>"+dataObj[i].preorderName+"</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" +
								"产地：<span class='goods_place'>"+dataObj[i].preorderCity+"</span> <br />" +
								"所在地址：<span class='goods_school'>"+dataObj[i].preorderAdess+"</span><br />" +
								"截止时间：<span class='goods_time'>"+dataObj[i].preorderCuttime+"</span> <br />" +
								"总价格：<span class='goods_price'>￥"+dataObj[i].preoderTotalprice+"</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" +
								"数量：<span class='goods_num'>"+dataObj[i].preorderCount+dataObj[i].preoderUnit+"</span><br />" +
								"<span class='state_txt'>" +
								"修改订单状态：" +
								"</span>" +
								"<select name='state' id='state' >" +

								"</select> " +
                                "<input id='button' type='button' _id='"+dataObj[i].preorderId+"' value='确认修改'>"+
								"</div>";
                        var select = $("#state");
						if(dataObj[i].preorderStatus==1){
                            select.append("<option value='2' selected='selected'>未发货</option>");
                            select.append("<option value='3'>运送中</option>");
                            select.append("<option value='4'>交易完成</option>");
						}else if(dataObj[i].preorderStatus==2){
                            select.append("<option value='3' selected='selected'>运送中</option>");
                            select.append("<option value='4'>交易完成</option>");
                        }else{
                            select.append("<option value='4' selected='selected'>交易完成</option>");
                        }

                        var makePass = $("#button");
                        makePass.click(function(){
//                            找到select的value值去更新
                            var preorderId = $(this).attr("_id")
                            var state = $("#state option:selected").text();
                            $.ajax("/fengwei/PreOrder/changeStatus",{
                                type:"post",
                                data:{
                                    'status':state,
                                    'preorderId':preorderId
                                },
                                success:function(){
                                    alert("修改成功")
                                },
                                error:function(){
                                    alert("修改不成功")
                                }

                            })
                        })
					}

				},
				error:function(){
					alert(0)
				}

			})
		</script>

	</head>
	<body>

		<div id="head">
			<a href=”#” onClick="javascript :history.back(-1);"> <img class="img_return" src="img/return.png"/> </a>
			<span class="head_txt">我的接单</span>
		</div>     <!--end -->
		
		<div id="orderList">
			<!--<div id="order_goods">-->
				<!--<div class="order_goods_msg">名称：<span class="goods_name">大闸蟹</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-->
								  	      <!--产地：<span class="goods_place">成都</span> <br />-->
								  	      <!--所在学校：<span class="goods_school">四川省 成都市 四川旅游学院</span><br />-->
								  	      <!--截止时间：<span class="goods_time">2017.3.3</span> <br />-->
								  	      <!--总价格：<span class="goods_price">￥50</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-->
	 								       <!--数量：<span class="goods_num">6kg</span><br />-->
	 			<!-- -->
	 			<!-- -->
		 			<!--<span class="state_txt">-->
		 				<!--修改订单状态：	-->
		 			<!--</span>-->
					<!--<select name="state" id="state" >-->
						<!--<option  value="1" selected="selected">未发货</option>-->
						<!--<option value="2">运送中</option>-->
						<!--<option value="2">交易完成</option>-->
					<!--</select>-->
				<!-- -->
				<!--</div>	-->
			<!--</div>   &lt;!&ndash;box end&ndash;&gt;-->
		</div>
	

		
	
	</body>
</html>
